<template>
  <div class="app-container">
    <!-- 查询和其他操作 -->
    <!-- <div class="filter-container">
      <el-input
        v-model="listQuery.userName"
        clearable
        class="filter-item"
        style="width: 200px"
        placeholder="请输入"
      />
      <el-button
        class="filter-item"
        type="primary"
        icon="el-icon-search"
        @click="handleFilter"
      >查找</el-button
      >
    </div> -->

    <!-- 查询结果 -->
    <el-table
      v-loading="listLoading"
      :data="list"
      size="small"
      element-loading-text="正在查询中。。。"
      border
      fit
      highlight-current-row
    >
      <!-- <el-table-column align="center" label="分享人" prop="adminName" /> -->

      <el-table-column align="center" label="分享到" prop="userName" />

      <el-table-column align="center" label="图片" width="80" prop="img">
        <template slot-scope="scope">
          <el-popover placement="right" trigger="hover">
            <!--trigger属性值：hover、click、focus 和 manual-->
            <img :src="scope.row.img" height="230" >
            <img slot="reference" :src="scope.row.img" height="23" >
          </el-popover>
        </template>
      </el-table-column>

      <el-table-column align="center" label="产品数" width="80" prop="img">
        <template slot-scope="scope">
          {{ scope.row.shareExtList.length }}
        </template>
      </el-table-column>

      <el-table-column align="center" label="创建时间" prop="createTime" />

    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getShareList } from '@/api/product'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

export default {
  name: 'ProductShare',
  components: { Pagination },
  data() {
    return {
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      getShareList(this.listQuery)
        .then((response) => {
          this.list = response.data.data.items
          this.total = response.data.data.total
          this.listLoading = false
        })
        .catch(() => {
          this.list = []
          this.total = 0
          this.listLoading = false
        })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    }
  }
}
</script>

<style></style>
